package com.zhaosc.proxy.advice;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

import com.zhaosc.configbean.Reference;
import com.zhaosc.invoke.Invocation;
import com.zhaosc.invoke.Invoke;

public class InvokeInvocationHandler implements InvocationHandler {

	private Invoke invoke;

	private Reference reference;

	public InvokeInvocationHandler(Invoke invoke, Reference reference) {
		this.invoke = invoke;
		this.reference = reference;
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		System.out.print("已经获取到了代理实例，已经掉到了InvokeInvocationHandler.invoke");
		
		Invocation invocation = new Invocation();
		invocation.setMethod(method);
		invocation.setParams(args);
		invocation.setReference(reference);
		String result=invoke.invoke(invocation);
		return result;

	}

}
